home *** CD-ROM | disk | FTP | other *** search
- Path: cpsc.ucalgary.ca!davidt
- From: davidt@cpsc.ucalgary.ca (David Taylor)
- Newsgroups: comp.lang.c++
- Subject: Re: clearing the screen, in Linux
- Date: 27 Mar 1996 23:20:12 GMT
- Organization: University of Calgary CPSC
- Message-ID: <4jcifc$bu3@linux.cpsc.ucalgary.ca>
- References: <31564CDA.DB1@ljusdal.se> <4j5k9r$as1@netnews.upenn.edu> <4j7qa2$5a8@crash.microserve.net>
- NNTP-Posting-Host: fsj.cpsc.ucalgary.ca
-
- In article <4j7qa2$5a8@crash.microserve.net>, <avenger@zola.trend1.com> wrote:
- >In <4j5k9r$as1@netnews.upenn.edu>, son@red.seas.upenn.edu (Sonny) writes:
- >>use the system function in
- >>#include<stdlib.h>
- >>
- >>system("clear");
- >>
- >
- >cout << "\027]2J";
- >
- >I think that should probably work. It will be faster as well.
-
- The "right" way to do this is with termcap or curses. That way it
- will work on any terminal.
-
- The termcap way is:
-
- char tbuffer[2048];
- char clearstr[20];
- char *area = clearstr;
-
- if (tgetent (tbuffer, getenv ("TERM")) < 0) {
- fprintf (stderr, "No termcap entry!\n");
- exit (1);
- }
-
- if (!tgetstr ("cl", &area))
- strcpy (clearstr, "");
-
-
- Now each time you print clearstr, the screen will clear. You might
- also need to link in -ltermcap.
-
- Using termcap and curses is cover in more detail in the Linux
- Programmer's Guide (freely available at http://sunsite.unc.edu/mdw).
-
- --
- Andrew Taylor |email: davidt@cpsc.ucalgary.ca
- |www: http://www.cpsc.ucalgary.ca/~davidt
-